import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import reducer from './reducer';

// 利用compose创建一个增强函数
const composeEnhancers =   window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}):compose;

// 通过增强函数，把thunk引入进来
const enhancer = composeEnhancers(applyMiddleware(thunk));

// 使用createStore 来引用reducer中返回的数据
const store = createStore(reducer, enhancer);
export default store;
